<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var numberOfWeakCharacters = function (properties) {
      properties.sort((o1, o2) => {
        return o1[0] === o2[0] ? (o1[1] - o2[1]) : (o2[0] - o1[0]);
      });
      let maxDef = 0;
      let ans = 0;
      for (const p of properties) {
        if (p[1] < maxDef) {
          ans++;
        } else {
          maxDef = p[1];
        }
      }
      return ans;
    };
    console.log(numberOfWeakCharacters([[5, 5], [6, 3], [3, 6]]));
  </script>

</body>

</html>